package normalEndPoint

import (
	"github.com/gin-gonic/gin"
	"taofoo.top/learn/email"
	"taofoo.top/learn/ginHelper"
)

type Mail struct {
	To      string
	Subject string
	Content string
}

//func sendMail(cc *gin.Context) {
//
//}

func SendMail(c *gin.Context) {
	mail := Mail{}
	err := c.ShouldBindQuery(&mail)
	if err != nil {
		return
	}
	//cc := c.Copy()
	go email.SendMail(mail.Subject,mail.Content,[]string{mail.To})
	c.JSON(200, gin.H{
		"msg": "ok",
	})
}

func init()  {
	register := ginHelper.NewGroupAndRegister("/v2","邮件发送接口")
	register.RegisterHandler(ginHelper.BaseHandler{BName: "sendMail",BGinHandler: SendMail})
}